<template>
  <span id="sidebar">
    <el-menu :default-active="currentPageName" :default-openeds="openedMenuList" class="el-menu-vertical-demo disabled-animation"
      @open="handleOpen" @close="handleClose" @select="selectMenu" text-color="#C8C8C8" active-text-color="#2d8cf0"
      background-color="#2463af" :collapse="isCollapse" :class="{'hide-sidebard-text': isCollapse}">
      <template v-for="item in menuList">
        <el-menu-item v-if="!item.children || item.children.length < 1" :index="item.name" :route="item" :key="item.index">
          <i :class="item.icon+' iconfont '" :key="item.index" style="width:24px"></i>
          <span class="sidebar-menu-text" :key="item.path" slot="title">{{ item.title }}</span>
        </el-menu-item>

        <el-submenu :index="item.name" v-if="item.children && item.children.length > 0" :key="item.path">
          <template slot="title">
            <i :class="item.icon+' iconfont '" :key="item.path" style="width:24px;color:#FFF;"></i>
            <span class="sidebar-menu-text" style="color:#FFF;">{{ item.title }}</span>
          </template>
          <el-menu-item :index="child.name" :route="child" :key="child.name" v-for="child in item.children">
            <i :class="child.icon+' iconfont '" :key="item.path" style="width:24px"></i>
            <span class="sidebar-menu-text" :key="child.name" slot="title">{{ child.title }}</span>
          </el-menu-item>
        </el-submenu>
      </template>
    </el-menu>

  </span>
</template>
<style>
  .el-menu-vertical-demo:not(.el-menu--collapse) {
    width: 250px;
    min-height: 400px;
  }

  /*.hide-sidebard-text .sidebar-menu-text {*/
  /*display: none;*/
  /*}*/

  /*.hide-sidebard-text i.ivu-menu-submenu-title-icon {*/
  /*display: none;*/
  /*}*/
</style>
<script>

import list from '@/views/manageOffice/assignList.vue'
import actionurl from '@/assets/js/actionurl.js'
  export default {
    name: 'sidebar',
    props: {
      theme: {
        type: String,
        default: 'dark'
      },
      isCollapse: {
        type: Boolean,
        default: false
      }
    },
    data() {
      return {
        currentPageName: null,
        openedMenuList: [],
        menuList:[]
      }
    },
    computed: {
      iconSize() {
        return 14
      },
      // menuList() {
      //   return this.$store.state.layout.menuList.slice()
      // }
      
    },
    watch: {
     
    },
    methods: {
      handleOpen(key, keyPath) {
        console.log(key, keyPath);
      },
      handleClose(key, keyPath) {
        console.log(key, keyPath);
      },
     
      
      selectMenu(menuName) {
    
        this.currentPageName = menuName
        this.$router.push({
          name: menuName
        })
      }
    },
    mounted() {
      this.menuList = [
        { title: '企业完善信息', path: '/companyInfoEdit', name: 'companyInfoEdit', icon: 'icon-fuwushang', meta: {title: "企业完善信息"}},
        { title: '提出问题', path: '/comQuestionList', name: 'comQuestionList', icon: 'icon-fuwushang',meta: {title: "提出问题"}}
      ]

     
     
    }

  }
</script>
<style scoped>
.el-menu-item i{
  color: #FFF;
}
</style>
